<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/dtree.css">
<link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/font/dtreefont.css">
<script th:inline="javascript">
/*<![CDATA[*/
var id=/*[[${id}]]*/
/*]]>*/
</script>
</head>
<body>
<form class="layui-form" lay-filter="myform" id="myform">
    <input type="hidden" name="id">
    <input type="hidden" name="currentNum" value="0">
    <div class="layui-form-item">
        <label class="layui-form-label">业务名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" id="name" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">编号前缀</label>
        <div class="layui-input-inline">
            <input type="text" name='prefix' id="prefix" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">编号类型</label>
        <div class="layui-input-inline">
            <input type="text" name="type" id="type" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">登记时间</label>
            <div class="layui-input-inline">
                <input type="text" name="createTime" id="createTime" lay-filter="createTime" th:value="${currentTime}" readonly="readonly" class="layui-input">
            </div>
        </div>
    </div>
    <button id="submitBtn" class="layui-btn" style="display:none" lay-submit lay-filter="submitme">保存</button>
</form>
<script th:src="@{/}+'js/day.js'"></script>
<script>
    layui.extend({
        tableSelect: '{/}layuiadmin/plugins/tableSelect' 
    });
    layui.extend({
        dtree: '{/}layuiadmin/plugins/dtree/dist/dtree' 
    });
    layui.use(['form', 'laydate','tableSelect','dtree'],function () {
        var form = layui.form
        ,layer = layui.layer
        ,tableSelect = layui.tableSelect
        ,dtree = layui.dtree;

        select("org/getList?orgType=head", "orgId",form,"name","id","","--公司--");

        form.on('submit(submitme)', function(data){

            var values = {};
            $(":input").each(function(i,v){
                values[v.name] = v.value;
            })
            axios.post('baseCodeNumber/save',values).then(res=>{
                if(res.data.code==1){
                    layer.msg(res.data.msg);
                }else{
                    layer.msg('保存成功');
                    let win=getTabWin();
                    win.loadGrid('featureTable');
                    var index = top.layer.getFrameIndex(window.name);
                    top.layer.close(index);
                }
            })
            return false;
        });


        if(id){
            loadData();
        }

        function loadData(){
            var entity = getEntityInfo(id,"baseCodeNumber/getById");
            form.val("myform",entity);
        }
    });
</script>
</body>
</html>